@extends('backend::layout')
@section('title',$page_title)
@section('content')
    @component('backend::component.table.table-content')
        @slot('page_title') {{$page_title}} @endslot
        @slot('tools_btn')
            @component('backend::component.form.button')
                @slot('title')添加管理员@endslot
                @slot('elem')a @endslot
                @slot('icon') hcl-user-add @endslot
                @slot('btn') btn @endslot
                @slot('size') sm @endslot
                @slot('href') {{route('b_Admin_showAddAdminForm')}} @endslot
            @endcomponent
        @endslot
        @slot('body_content')
            <table class="table table-bordered table-striped">
                <thead>
                <tr>
                    <th>
                            @component('backend::component.checkbox')
                                @slot('name') ids-all @endslot
                            @endcomponent
                    </th>
                    <th>账号</th><th>角色</th><th>登录次数</th><th>创建时间</th><th>状态</th><th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($list as $value)
                    <tr>
                        <td>
                            @if($login_info['mgr_id'] != $value->mgr_id)
                                    @component('backend::component.checkbox')
                                        @slot('name') id[] @endslot
                                        @slot('class') id @endslot
                                        @slot('value') {{$value->mgr_id}} @endslot
                                    @endcomponent
                                @else
                                <span class="hcl hcl-admin" style="font-size: 22px;color:#f86c6b;font-weight: 600;"></span>
                            @endif
                        </td>
                        <td>{{$value->mgr_name}}[{{$value->mgr_email}}]</td>
                        <td>
                            @if($value->is_super == 1)
                                <code class="code"> 所有角色</code>
                            @else
                                @if($value->my_roles)
                                    @foreach(str2arr($value->my_roles) as $key=>$id)
                                        <code class="code">{{$roles[$id] ?? ''}}</code>
                                    @endforeach
                                @else
                                  <code class="code">未分配角色</code>
                                @endif

                            @endif
                        </td>
                        <td>{{$value->login_count}}</td>
                        <td>{{date('Y-m-d',$value->created_at)}}</td>
                        <td>
                            @if($login_info['mgr_id'] != $value->mgr_id)
                                @component("backend::component.switch")
                                    @slot('params'){"url":"{{route('b_Admin_switchAdminStatus',['admin_name'=>$value->mgr_name])}}"} @endslot
                                    @slot('checked') @if($value->is_enable == 1) checked @endif @endslot
                                @endcomponent
                            @else
                                正常
                            @endif
                        </td>
                        <td>
                            @if($login_info['mgr_id'] != $value->mgr_id)
                                @component('backend::component.form.button')
                                    @slot('title')重置密码@endslot
                                    @slot('elem') a @endslot
                                    @slot('btn') btn @endslot
                                    @slot('size') sm @endslot
                                    @slot('color') danger @endslot
                                    @slot('class') modal-box @endslot
                                    @slot('params') {"area":"600px,500px","title":"重置密码"} @endslot
                                    @slot('href') {{route('b_Admin_resetPwdForm',['admin_name'=>$value->mgr_name])}} @endslot
                                @endcomponent

                                @component('backend::component.form.button')
                                    @slot('title') 删除 @endslot
                                    @slot('color') danger @endslot
                                    @slot('size') sm @endslot
                                    @slot('params') {"url":"{{route('b_Admin_delete',['admin_name'=>$value->mgr_name])}}","confirm":"true"} @endslot
                                    @slot('class') btn-ajax @endslot
                                @endcomponent
                            @else
                                @component('backend::component.form.button')
                                    @slot('title')修改密码@endslot
                                    @slot('elem') a @endslot
                                    @slot('btn') btn @endslot
                                    @slot('size') sm @endslot
                                    @slot('color') danger @endslot
                                    @slot('class') modal-box @endslot
                                    @slot('params') {"area":"600px,500px","title":"修改密码"} @endslot
                                    @slot('href') {{route('b_Admin_changePwdForm')}} @endslot
                                @endcomponent
                            @endif

                            @component('backend::component.form.button-group')
                                @slot('button_title')
                                    @component('backend::component.form.button')
                                        @slot('title') 更多操作 @endslot
                                        @slot('color') primary @endslot
                                        @slot('size') sm @endslot
                                        @slot('class') dropdown-toggle @endslot
                                        @slot('attr') data-toggle=dropdown @endslot
                                    @endcomponent
                                @endslot
                                @slot('button_item')
                                    @component('backend::component.form.button')
                                        @slot('title') 编辑 @endslot
                                        @slot('elem') a @endslot
                                        @slot('class') dropdown-item modal-box @endslot
                                        @slot('params') {"area":"600px,500px","title":"编辑{{$value->mgr_name}}信息"} @endslot
                                        @slot('href') {{route('b_Admin_showEditAdminForm',['admin_name'=>$value->mgr_name])}} @endslot
                                    @endcomponent

                                    @component('backend::component.form.button')
                                        @slot('title') 详细信息 @endslot
                                        @slot('elem') a @endslot
                                        @slot('class') dropdown-item modal-box @endslot
                                        @slot('params') {"area":"650px,500px","title":"编辑{{$value->mgr_name}}信息"} @endslot
                                        @slot('href') {{route('b_Admin_info',['admin_name'=>$value->mgr_name])}} @endslot
                                    @endcomponent

                                        @if($value->is_super != 1)
                                                @component('backend::component.form.button')
                                                    @slot('title') 分配角色 @endslot
                                                    @slot('elem') a @endslot
                                                    @slot('class') dropdown-item modal-box @endslot
                                                    @slot('params') {"area":"600px,500px","title":"编辑{{$value->mgr_name}}分配角色"} @endslot
                                                    @slot('href') {{route('b_Admin_grantRoles',['admin_name'=>$value->mgr_name])}} @endslot
                                                @endcomponent
                                        @endif
                                @endslot
                            @endcomponent
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        @endslot
    @endcomponent
@endsection